/*
 * @Author: szx
 * @Date: 2022-03-18 15:09:51
 * @LastEditTime: 2022-03-18 15:18:06
 * @Description:
 * @FilePath: \leetcode\400-499\435\435.js
 */
/**
 * @param {number[][]} intervals
 * @return {number}
 */
var eraseOverlapIntervals = function (intervals) {
    intervals.sort((a, b) => a[1] - b[1]);
    console.log(intervals);
    let res = 1;
    let min = intervals[0][1];
    for (let i = 1; i < intervals.length; i++) {
        if (intervals[i][0] >= min) {
            min = intervals[i][1];
            res++;
        }
    }
    return intervals.length - res;
};
console.log(
    eraseOverlapIntervals([
        [1, 2],
        [2, 3],
        [3, 4],
        [1, 3]
    ])
);
console.log(
    eraseOverlapIntervals([
        [1, 2],
        [1, 2],
        [1, 2]
    ])
);
